/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/3/11
 * Time: 12:34 AM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.*;
import java.io.IOException;

public class Shooting extends Thread {

    public Shooting() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static class Graph {

        public Graph(int n) {
            this.g = new ArrayList [n];
            for (int i = 0; i < n; ++i) {
                this.g[i] = new ArrayList<Integer>();
            }
            this.d = new int [n];
            this.p = new int[n];
            this.edges = new Edge[40000];
        }
        static class Edge {
            int from, to, c, f;
            public Edge(int from, int to, int c) {
                this.from = from;
                this.to = to;
                this.c = c;
                this.f = 0;
            }
        }

        private boolean bfs() {
            q.clear();
            q.add(s);
            Arrays.fill(d, -1);
            d[s]  = 0;
            while (!q.isEmpty() && d[t] == -1) {
                int current = q.poll();
                for (int id : g[current]) {
                    int to = edges[id].to;
                    if (d[to] == -1 && edges[id].f < edges[id].c) {
                        q.add(to);
                        d[to]  = d[current]  + 1;
                    }
                }
            }

            return d[t] != -1;
        }

        private int dfs(int v, int flow) {
            if (v == t || flow == 0) {
                return flow;
            }
            int result = 0;
            for (; p[v] < g[v].size(); ++p[v]) {
                int id = g[v].get(p[v]), to = edges[id].to;
                if (d[to] != d[v] + 1) {
                    continue;
                }
                int current = dfs(to, Math.min(flow, edges[id].c - edges[id].f));
                edges[id].f += current;
                edges[id ^ 1].f -= current;
                flow -= current;
                result += current;
                if (flow == 0) {
                    return result;
                }
            }

            return result;
        }

        public void setNetwork(int s, int t) {
            this.s = s;
            this.t = t;
        }

        public int maxFlow() {
            int flow = 0, current = 0;
            while (bfs()) {
                Arrays.fill(p, 0);
                while ((current = dfs(s, Integer.MAX_VALUE)) != 0) {
                    flow += current;
                }
            }

            return flow;
        }

        public void addEdge(int a, int b) {
            Edge first = new Edge(a, b, 1);
            g[a].add(SIZE);
            edges[SIZE++] = first;
            Edge second = new Edge(b, a, 0);
            g[b].add(SIZE);
            edges[SIZE++] = second;
        }

        int []d;
        int []p;
        List<Integer> []g;
        Edge[]  edges;
        int s, t, SIZE = 0;
        Queue<Integer> q = new ArrayDeque<Integer>();



    }

    public void run() {
        try {
            int n = nextInt(), m = nextInt();
            Graph g = new Graph(2 * n + 2);
            g.setNetwork(0, 2 * n + 1);
            for (int i = 0; i < m; ++i) {
                int a = nextInt(), b = nextInt();
                g.addEdge(a, n + b);
                g.addEdge(b, n + a);
            }
            for (int i = 1; i <= n; ++i) {
                g.addEdge(0, i);
                g.addEdge(n + i, 2 * n + 1);
            }
            int flow = g.maxFlow();
            if (flow != n) {
                output.println("Impossible");
            } else {
                for (int i = 1; i <= n; ++i) {
                    for (int current : g.g[i]) {
                        if (g.edges[current].f != 0) {
                              output.println(g.edges[current].to > n ? g.edges[current].to - n : g.edges[current].to);
                            break;
                        }
                    }
                }
            }

            output.flush();
            output.close();

        } catch (Throwable e) {
            System.err.println(e.getMessage());
            System.err.println(Arrays.deepToString(e.getStackTrace()));
        }
    }


    public static void main(String[] args) {
        new Shooting().start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }


    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}
